<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cautare extends CI_Controller {

	public function __construct()
    {
        parent::__construct();
        $this->load->model('film');
        $this->load->model('loginmodel');
    }

	public function index()
	{
		$logat = $this->loginmodel->este_logat();
		$data['titlu'] = 'Star Cinema | Cautare';
		$logat = $this->loginmodel->este_logat();
		$data['logat'] = $logat;
		if($logat)
		{
			$data['nume'] = $this->session->userdata('nume');
			$data['prenume'] = $this->session->userdata('prenume');
		}

		$this->load->view('home/header', $data);

		$searched = $this->input->post('termen');
		if($searched)
		{
			$data2['rezultate'] = $this->film->get_films($searched);
			$this->load->view('filme/content', $data2);
		}
		else
		{
			$this->load->view('filme/content');
		}
		$this->load->view('home/footer');
	}

	public function view_film($id)
	{
		$logat = $this->loginmodel->este_logat();
		$data['titlu'] = 'Star Cinema | Filme';
		$logat = $this->loginmodel->este_logat();
		$data['logat'] = $logat;
		if($logat)
		{
			$data['nume'] = $this->session->userdata('nume');
			$data['prenume'] = $this->session->userdata('prenume');
		}

		$data2['film'] = $this->film->get_film($id);
		
		$this->load->view('home/header', $data);
		$this->load->view('view_film/content', $data2);		
		$this->load->view('home/footer');
	}
}